<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-bind命令的拓展</title>
    <style>
        p{
            width:200px;
            height:200px;
            background:blue;
        }
        .red{background: red;}
        .pink{background: pink;}
    </style>
</head>
<body>
    <div id="app" >
        <div>
            <p >{{a}}--{{b}}</p>
            <p :style="{background:this.colorDemo}">{{a}}</p>
        </div>
        <button @click="add">点我加1</button>
        <button  @click="minus">点我减1</button>
    </div>
    <script src="js/vue2.js"></script>
    <script >
            new Vue({
                el: '#app',
                data: {
                    a: 0,
                    b: 100,
                    colorDemo: 'blue'
                },
                methods: {
                    add() {
                        this.a += 5;
                        if (this.a >= 15) {
                            this.colorDemo = 'red';
                        }
                        if (this.a >= 30) {
                            this.colorDemo = 'pink';
                        }
                    }, minus() {
                        this.b -= 5;
                        if (this.b >= 15) {
                            this.colorDemo = 'red';
                        }
                        if (this.b >= 30) {
                            this.colorDemo = 'pink';
                        }
                    }
                }
            })
    </script>
</body>
</html>